package com.beimihu.leetcode;

public class RotateArray {
    private static void reverse(int [] nums,int start , int end){
        for(int i = start,j = end ; i < j; i++,j--){
            int temp = nums[j];
            nums[j] =  nums[i];
            nums[i] = temp;
        }
    }

    public static void main(String[] args) {
        int[] nums = {1,2,3,4,5};
        int n = nums.length;
        int k = 3;
        reverse(nums,0,k-1);
        reverse(nums,k,n-1);
        reverse(nums,0,n-1);

//        reverse(nums,0,2);
        for (int num : nums){
            System.out.println(num);
        }
    }
}
